package com.homson.coreservice.serviceinfrastructure.config;

import com.homson.coreservice.servicecommon.utils.ApiKeyUtils;
import dev.langchain4j.community.model.dashscope.QwenChatModel;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

@Configuration
public class AiModelConfig {
    
    @Bean("qwenModel")
    public ChatModel qwenConfigBean() {
        Properties apiKeys = ApiKeyUtils.loadApiKeys();
        ChatModel qwenModel = QwenChatModel.builder()
                .apiKey(apiKeys.getProperty("qwen"))
                .modelName("qwen2.5-72b-instruct")
                .build();
        
        return qwenModel;
    }
    
    @Bean("openAiModel")
    public ChatModel poeConfigBean() {
        Properties apiKeys = ApiKeyUtils.loadApiKeys();
        ChatModel openAiModel = OpenAiChatModel.builder()
                .apiKey(apiKeys.getProperty("poe"))
                .modelName("gpt-4o-mini")
                .baseUrl("https://api.poe.com/v1")
                .build();
        
        return openAiModel;
    }
}
